<?php 

function fudum_resources() {
	wp_enqueue_style('style', get_stylesheet_uri());
}

add_action('wp_enqueue_scripts', 'fudum_resources');

// Navigation Menus
register_nav_menus(array(
	'primary' => __( 'Primary Menu'),
	'footer' => __( 'Footer Menu'),
));

function custom_expert_lenght() {
	return 200;
}

add_filter('excerpt_length', 'custom_expert_lenght');


// chinese expert();
/*
function excerpt_read_more_link($output) {
	global $post;
	$output = mb_substr($output,0, 200);
	return $output;
}
add_filter('the_excerpt', 'excerpt_read_more_link');
*/


// Get to ancestor
function get_top_ancestor_id() {

	global $post;

	if ($post->post_parent) {
		$ancestors = array_reverse(get_post_ancestor($post->ID));
		return $ancestors[0];
	}

	return $post->ID;
}

// Add Our Widget Locations
function ourWidgetInit() {

	register_sidebar( array(
		'name' => 'Siderbar',
		'id' => 'sidebar1',
		'before_widget' => '<div class= "widget-item">',
		'after_widget' => '</div>',
		'before_title' => '<h4 class="my-special-class">',
		'after_title' => '</h4>'
	));

	register_sidebar( array(
		'name' => 'Footer Area 1',
		'id' => 'footer1'
	));

	register_sidebar( array(
		'name' => 'Footer Area 2',
		'id' => 'footer2'
	));

	register_sidebar( array(
		'name' => 'Footer Area 3',
		'id' => 'footer3'
	));

	register_sidebar( array(
		'name' => 'Footer Area 4',
		'id' => 'footer4'
	));
}

add_action('widgets_init', 'ourWidgetInit');


// Theme setup
function fudum_setup()
{
	//Add featured image support
	add_theme_support('post-thumbnails');
}

add_action('after_setup_theme', 'fudum_setup');

// comments 
if ( ! function_exists( 'fudum_comment' ) ) :
function fudum_comment( $comment, $args, $depth ) {
	$GLOBALS['comment'] = $comment;
	switch ( $comment->comment_type ) :
		case 'pingback' :
		case 'trackback' :
	?>
	<li class="post pingback">
		<p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>
	<?php
			break;
		default :
	?>
	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
		<article id="comment-<?php comment_ID(); ?>" class="comment">
			<footer class="comment-meta">
				<div class="comment-author vcard">
					<?php
					$avatar_size = 68;
					if ( '0' != $comment->comment_parent )
						$avatar_size = 39;

					echo get_avatar( $comment, $avatar_size ); ?>

					<span class="fn">
						<?php  echo get_comment_author_link() . " 评论：" ?>
					</span>
					<span class="c-time">
						<?php echo get_comment_date("Y/m/d") . " " . get_comment_time("H:i:s"); ?>
					</span>
			</footer>

			<div class="comment-content">
				<?php comment_text(); ?>
					
			</div>

			<div class="reply">
				<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( '回复', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
			</div><!-- .reply -->
		</article><!-- #comment-## -->

	<?php
			break;
	endswitch;
}
endif; // ends check for fudum_comment()


show_admin_bar(false); //关闭工具条显示

?>